package com.health.db.service.sm.impl;

import com.health.db.service.sm.IWXPayService;
import com.health.pay.tencent.WXPay;
import com.health.pay.tencent.common.Configure;
import com.health.pay.tencent.common.RandomStringGenerator;
import com.health.pay.tencent.protocol.closeorder.CloseOrderReqData;
import com.health.pay.tencent.protocol.closeorder.CloseOrderResData;
import com.health.pay.tencent.protocol.orderquery.OrderQueryReqData;
import com.health.pay.tencent.protocol.orderquery.OrderQueryResData;
import com.health.pay.tencent.protocol.refund.RefundReqData;
import com.health.pay.tencent.protocol.refund.RefundResData;
import com.health.pay.tencent.protocol.transfers.TransfersReq;
import com.health.pay.tencent.protocol.transfers.TransfersResp;
import com.health.pay.tencent.protocol.unifiedorder.UnifiedorderReqData;
import com.health.pay.tencent.protocol.unifiedorder.UnifiedorderResData;
import com.sun.istack.internal.NotNull;

public class WXPayServiceImpl implements IWXPayService {
	

	@Override
	public CloseOrderResData closeOrder(CloseOrderReqData closeOrderReqData) throws Exception {
		// TODO Auto-generated method stub
		return WXPay.closeOrder(closeOrderReqData);
	}

	@Override
	public OrderQueryResData queryOrder(OrderQueryReqData orderQueryReqData)throws Exception {
		// TODO Auto-generated method stub
		return WXPay.queryOrder(orderQueryReqData);
	}

	@Override
	public RefundResData refund(RefundReqData refundReqData) throws Exception{
		// TODO Auto-generated method stub
		return WXPay.refund(refundReqData);
	}
	
	@Override
	public TransfersResp transfers(TransfersReq transfersReq) throws Exception {
		// TODO Auto-generated method stub
		return WXPay.transfers(transfersReq);
	}
	
	
	/**
	 * 统一下单
	 * */
	@Override
	public UnifiedorderResData unifiedorder(String deviceInfo, String body,
			String detail, String attach, String outTradeNo, String totalFee,
			String timeStart, String timeExpire, String limitPay)
			throws Exception {
		// TODO Auto-generated method stub
		UnifiedorderReqData reqData=new UnifiedorderReqData(deviceInfo, 
				RandomStringGenerator.getRandomStringByLength(32), 
				"MD5", body, detail, attach, 
				outTradeNo, totalFee, Configure.ip, timeStart, timeExpire,  Configure.notifyUrl, limitPay);
		return WXPay.unifiedorder(reqData);
	}

	/***
	 * 微信浏览器H5统一下单
	 * */
	@Override
	public UnifiedorderResData unifiedH5order(String deviceInfo, @NotNull String body, String detail,
									   String attach, @NotNull String outTradeNo,
									   @NotNull String totalFee,String spbillCreateIp,
									   String timeStart, String timeExpire,
									   String limitPay,String sceneInfo)throws Exception
	{
		UnifiedorderReqData reqData=new UnifiedorderReqData(deviceInfo,
				RandomStringGenerator.getRandomStringByLength(32),
				"MD5", body, detail, attach,
				outTradeNo, totalFee, spbillCreateIp, timeStart, timeExpire,  Configure.notifyUrl, "MWEB",limitPay,sceneInfo);
		return WXPay.unifiedorder(reqData);
	}
	
	/***
	 * 微信小程序统一下单
	 * */
	@Override
	public UnifiedorderResData unifiedMiNiProgramorder(String deviceInfo, @NotNull String body, String detail,
									   String attach, @NotNull String outTradeNo,
									   @NotNull String totalFee,String spbillCreateIp,
									   String timeStart, String timeExpire,
									   String limitPay,String openId)throws Exception
	{
		UnifiedorderReqData reqData=new UnifiedorderReqData(deviceInfo,
				RandomStringGenerator.getRandomStringByLength(32),
				"MD5", body, detail, attach,
				outTradeNo, totalFee, spbillCreateIp, timeStart, timeExpire,  Configure.notifyUrl, "JSAPI",limitPay,openId,null,null);
		return WXPay.unifiedorder(reqData);
	}
	

	@Override
	public UnifiedorderResData unifiedMPorder(String deviceInfo, String body, String detail, String attach, String outTradeNo, String totalFee, String spbillCreateIp, String timeStart, String timeExpire, String limitPay, String openid, String sceneInfo) throws Exception {
		UnifiedorderReqData reqData=new UnifiedorderReqData(deviceInfo,
				RandomStringGenerator.getRandomStringByLength(32),
				"MD5", body, detail, attach,
				outTradeNo, totalFee, spbillCreateIp, timeStart, timeExpire,  Configure.notifyUrl, "JSAPI",limitPay,sceneInfo,openid);
		return WXPay.unifiedorder(reqData);
	}

}
